import { useChatStore } from '@/store'

export function useChat() {
  const chatStore = useChatStore()

  const addChat = (uuid: number, chat: Chat.Chat) => {
    chatStore.addChatByUuid(uuid, chat)
  }

  const updateChat = (uuid: number, index: number, chat: Chat.Chat) => {
    chatStore.updateChatByUuid(uuid, index, chat)
  }

  const appendChatByUUid = (uuid:number, index:number, chat:Chat.Chat)=>{
    chatStore.appendChatByUUid(uuid, index, chat)
  }

  const getLastChatMessageInfo = (uuid: number, index: number) =>{
    return chatStore.getChatByUuidAndIndex(uuid, index)
  }

  const setSendMsgInfo = (chat:Chat.SendMsg) =>{
    return chat
  }


  const setSendMsg1Info = (chat:Chat.SendMsg1) =>{
    return chat
  }



  const  getHistoryTile = (uuid: number) =>{
    return chatStore.getHistoryTitle(uuid)
  }

  return {
    addChat,
    updateChat,
    getLastChatMessageInfo,
    appendChatByUUid,
    setSendMsgInfo,
    setSendMsg1Info,
    getHistoryTile
  }
}
